

*1.) BLS: Compute LS decline by NAICS-3 industry

import excel "BLS_mfg_data.xlsx", sheet("Sheet1") firstrow clear
rename code naics3
save aux_mfg_data, replace

keep if naics3==311312
replace naics3=311
save aux, replace

use aux_mfg_data, clear
keep if naics3==311312
replace naics3=312
append using aux
save aux, replace

use aux_mfg_data, clear
keep if naics3==313314
replace naics3=313
append using aux
save aux, replace

use aux_mfg_data, clear
keep if naics3==313314
replace naics3=314
append using aux
save aux, replace

use aux_mfg_data, clear
keep if naics3==315316
replace naics3=315
append using aux
save aux, replace

use aux_mfg_data, clear
keep if naics3==315316
replace naics3=316
append using aux
save aux, replace

use aux_mfg_data, clear
keep if naics3<311312
append using aux
save aux_mfg_data, replace

xtset naics3 year
gen double va=(output-intermediates)
gen double ls = laborcost/va
gen double t=year-1987
gen double tt = t^2

egen double va_agg = sum(va), by(year)
gen double BLS_om7a = va/va_agg
gen double BLS_om7a_87 = BLS_om7a if year==1987
gen double BLS_om7a_12 = BLS_om7a if year==2012

gen double BLS_LS_diff_tr     = .
foreach i of numlist 311/316 321/327 331/337 339 {
   di "Industry `i'"
   reg ls t                                   if naics3==`i' & year>=1987 & year<=2012
   replace BLS_LS_diff_tr = 25*_b[t]              if naics3==`i'
}
gen ls_1987 = ls if year==1987
gen ls_2012 = ls if year==2012

collapse BLS_om* BLS_LS_* ls_1987 ls_2012, by(naics3)
gen BLS_LS_diff_yr = ls_2012-ls_1987

keep naics3 BLS_om* BLS_LS_diff*
save aux_BLS_LS_tr, replace


*2.) Redo with the NBER-CES mfg database
use "naics5811.dta", clear
gen int naics3=int(naics/1000)
collapse (sum) vship matcost energy vadd emp pay, by(year naics3)
gen double va = vship - matcost - energy
gen double ls = pay/vadd

egen double va_agg = sum(va), by(year)
gen double NBERCES_om7a = va/va_agg
gen double NBERCES_om7a_87 = NBERCES_om7a if year==1987
gen double NBERCES_om7a_11 = NBERCES_om7a if year==2011

gen double NBERCES_LS_diff_tr     = .
gen double NBERCES_LS_diff_lq     = .
gen double t=year-1987
gen double tt = t^2

foreach i of numlist 311/316 321/327 331/337 339 {
   di "Industry `i'"
   reg ls t                                   if naics3==`i' & year>=1987 & year<=2012
   replace NBERCES_LS_diff_tr = 25*_b[t]       if naics3==`i'

   reg ls t tt                                if naics3==`i' & year>=1987 & year<=2012
   replace NBERCES_LS_diff_lq = 25*(_b[t]+25*_b[tt])       if naics3==`i'
}
gen ls_1987 = ls if year==1987
gen ls_2011 = ls if year==2011

collapse NBERCES_om* NBERCES_LS_* ls_1987 ls_2011, by(naics3)
gen NBERCES_LS_diff_yr = ls_2011-ls_1987

keep naics3 NBERCES_om* NBERCES_LS_diff*
merge 1:1 naics3 using aux_BLS_LS_tr
drop _merge
save LS_tr, replace


browse





















